import { viteMockServe } from 'vite-plugin-mock'
export default (viteEnv: ImportMetaEnv, isBuild = false) => {
  return viteEnv.VITE_USE_MOCK
    ? viteMockServe({
        ignore: /^\_/,
        mockPath: 'mock',
        localEnabled: !isBuild,
        prodEnabled: isBuild,
        injectCode: `
          import { setupProdMockServer } from '../mock/_mockProdServer'
          set
        `
      })
    : undefined
}
